package com.wyk.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wyk.admin.common.convention.result.Result;
import com.wyk.admin.common.convention.result.Results;
import com.wyk.admin.remote.ShortLinkActualRemoteService;
import com.wyk.admin.remote.dto.req.RecycleBinDeleteReqDTO;
import com.wyk.admin.remote.dto.req.RecycleBinRecoverReqDTO;
import com.wyk.admin.remote.dto.req.RecycleBinSaveReqDTO;
import com.wyk.admin.remote.dto.req.ShortLinkRecycleBinPageReqDTO;
import com.wyk.admin.remote.dto.resp.ShortLinkPageRespDTO;
import com.wyk.admin.service.RecycleBinService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController(value = "recycleBinControllerByAdmin")
@RequiredArgsConstructor
public class RecycleBinController {

    private final RecycleBinService recycleBinService;

    private final ShortLinkActualRemoteService shortLinkSAActualRemoteService;


    /**
     * 后管 保存回收站
     * @param requestParam
     * @return
     */
    @PostMapping("/api/short-link/admin/v1/recycle-bin/save")
    public Result<Void> saveRecycle(@RequestBody RecycleBinSaveReqDTO requestParam){
        shortLinkSAActualRemoteService.saveRecycleBin(requestParam);
        return Results.success();
    }

    /**
     * 分页查询 回收站
     * @param requestParam
     * @return
     */
    @GetMapping("/api/short-link/admin/v1/recycle-bin/page")
    public Result<Page<ShortLinkPageRespDTO>> pageRecycleBinshortLink(ShortLinkRecycleBinPageReqDTO requestParam) {
        return recycleBinService.pageRecycleBinshortLink(requestParam);
    }

    /**
     *  回收站恢复短连接
     * @param requestParam
     * @return
     */
    @PostMapping("/api/short-link/admin/v1/recycle-bin/recover")
    public Result<Void> recoverRecycleBin(@RequestBody RecycleBinRecoverReqDTO requestParam) {
        shortLinkSAActualRemoteService.recoverRecycleBin(requestParam);
        return Results.success();
    }

    /**
     * 回收站删除短连接
     * @param requestParam
     * @return
     */
    @PostMapping("/api/short-link/admin/v1/recycle-bin/remove")
    public Result<Void> removeRecycleBin(@RequestBody RecycleBinDeleteReqDTO requestParam) {
        shortLinkSAActualRemoteService.removeRecycleBin(requestParam);
        return Results.success();
    }
}